home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / tcl / tcl70b2.lha / tcl7.0b2 / tests / split.test < prev    next >
Text File  |  1993-02-06  |  2KB  |  59 lines

  1. # Commands covered:  split
  2. #
  3. # This file contains a collection of tests for one or more of the Tcl
  4. # built-in commands.  Sourcing this file into Tcl runs the tests and
  5. # generates output for errors.  No output means no errors were found.
  6. #
  7. # Copyright (c) 1991-1993 The Regents of the University of California.
  8. # All rights reserved.
  9. #
  10. # Permission is hereby granted, without written agreement and without
  11. # license or royalty fees, to use, copy, modify, and distribute this
  12. # software and its documentation for any purpose, provided that the
  13. # above copyright notice and the following two paragraphs appear in
  14. # all copies of this software.
  15. #
  16. # IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR
  17. # DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
  18. # OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF
  19. # CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  20. #
  21. # THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
  22. # INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
  23. # AND FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS
  24. # ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO
  25. # PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
  26. #
  27. # $Header: /user6/ouster/tcl/tests/RCS/split.test,v 1.4 93/02/06 16:01:36 ouster Exp $ (Berkeley)
  28.  
  29. if {[string compare test [info procs test]] == 1} then {source defs}
  30.  
  31. test split-1.1 {basic split commands} {
  32.     split "a\n b\t\r c\n "
  33. } {a {} b {} {} c {} {}}
  34. test split-1.2 {basic split commands} {
  35.     split "word 1xyzword 2zword 3" xyz
  36. } {{word 1} {} {} {word 2} {word 3}}
  37. test split-1.3 {basic split commands} {
  38.     split "12345" {}
  39. } {1 2 3 4 5}
  40. test split-1.4 {basic split commands} {
  41.     split "a\}b\[c\{\]\$"
  42. } "a\\}b\\\[c\\{\\\]\\\$"
  43. test split-1.5 {basic split commands} {
  44.     split {} {}
  45. } {}
  46. test split-1.6 {basic split commands} {
  47.     split {}
  48. } {}
  49. test split-1.7 {basic split commands} {
  50.     split {   }
  51. } {{} {} {} {}}
  52.  
  53. test split-2.1 {split errors} {
  54.     list [catch split msg] $msg $errorCode
  55. } {1 {wrong # args: should be "split string ?splitChars?"} NONE}
  56. test split-2.2 {split errors} {
  57.     list [catch {split a b c} msg] $msg $errorCode
  58. } {1 {wrong # args: should be "split string ?splitChars?"} NONE}
  59.